home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / acad / autolisp / sfill / sfill.lsp
Lisp/Scheme  |  1988-07-14  |  5KB  |  173 lines

  1. ; SFILL.LSP   1.0 July 14 1988
  2. ; By Jamie Clay
  3. ; [76703,4204]
  4. ;
  5. ; SFILL will construct an even division of SOLIDs between any 2 Arcs, 
  6. ; Lines or Polylines on any elevation plane.
  7. ;
  8. ; This routine was once RULESURF.lsp and much of the code was designed
  9. ; to collect and use 3dpoints for 3dfaces. It works well with the SOLID
  10. ; entity and I think you will find it very useful. Please feel free
  11. ; to modify and improve this code.
  12. ;
  13. ; Note: the entities must "read" in the same direction, else you will
  14. ; get a major bow tie effect.
  15.  
  16. (vmon)
  17. (setq res "10")
  18.  
  19. ; SPATHA Set up first path's point set
  20. (defun spatha (/ path1) 
  21.   (while (= entcheck nil) 
  22.     (setq patha (entsel "\nSelect first surface path: ")) 
  23.     (setq getit (cadr patha)) 
  24.     (setq patha (car patha)) 
  25.     (setq path1 (entget patha)) 
  26.     (if (assoc 38 path1) 
  27.       (setq elev1 (list (cdr (assoc 38 path1)))) 
  28.       (setq elev1 '(0)) 
  29.     ) 
  30.     (setq entcheck (cdr (assoc 0 path1))) 
  31.     (if (/= entcheck "POLYLINE") 
  32.       (if (or (= entcheck "ARC") (= entcheck "LINE")) 
  33.         (progn 
  34.           (command "PEDIT" patha "Y" "") 
  35.           (setq patha (ssget getit)) 
  36.           (setq patha (ssname patha 0)) 
  37.         ) 
  38.         (progn 
  39.           (Prompt "\nPlease use Arcs, Lines or Polylines!") 
  40.           (setq entcheck nil) 
  41.         ) 
  42.       ) 
  43.     ) 
  44.   ) 
  45.   (setq entcheck nil) 
  46.   (setq pathlist path1) 
  47.   (setq pathent patha) 
  48.   (pathout) 
  49.   (setq patha pnts) 
  50.  
  51. ; SPATHB set up second path's point set
  52. (defun spathb (/ path2) 
  53.   (while (= entcheck nil) 
  54.     (setq pathb (entsel "\nSelect second surface path: ")) 
  55.     (setq getit (cadr pathb)) 
  56.     (setq pathb (car pathb)) 
  57.     (setq path2 (entget pathb)) 
  58.     (if (assoc 38 path2) 
  59.       (setq elev2 (list (cdr (assoc 38 path2)))) 
  60.       (setq elev2 '(0)) 
  61.     ) 
  62.     (setq entcheck (cdr (assoc 0 path2))) 
  63.     (if (/= entcheck "POLYLINE") 
  64.       (if (or (= entcheck "ARC") (= entcheck "LINE")) 
  65.         (progn 
  66.           (command "PEDIT" pathb "Y" "") 
  67.           (setq pathb (ssget getit)) 
  68.           (setq pathb (ssname pathb 0)) 
  69.         ) 
  70.         (progn 
  71.           (Prompt "\nPlease use Arcs, Lines or Polylines!") 
  72.           (setq entcheck nil) 
  73.         ) 
  74.       ) 
  75.     ) 
  76.   ) 
  77.   (setq entcheck nil) 
  78.   (setq pathlist path2) 
  79.   (setq pathent pathb) 
  80.   (pathout) 
  81.   (setq pathb pnts) 
  82.  
  83.  
  84. ; PATHOUT - Divide and collect points
  85. (defun pathout (/ 1stpt) 
  86.   (while (/= stop "SEQEND") 
  87.     (progn 
  88.       (setq lastpl pathlist) 
  89.       (if (/= stop "SEQEND") 
  90.         (progn 
  91.           (setq pathlist (entget (setq pathent (entnext pathent)))) 
  92.           (if (= 1stpt nil) 
  93.             (setq 1stpt (cdr (assoc 10 pathlist))) 
  94.           ) 
  95.         ) 
  96.       ) 
  97.     ) 
  98.     (setq stop (cdr (assoc 0 pathlist))) 
  99.   ) 
  100.   (setq pnts 1stpt) 
  101.   (setq lastpt (cdr (assoc 10 lastpl))) 
  102.   (command "layer" "M" "$nodes" "") 
  103.   (command "divide" getit res) 
  104.   (setq points (ssget "x" '((8 . "$NODES")(0 . "POINT")))) 
  105.   (setq index (1- (sslength points))) 
  106.   (while (/= index -1) 
  107.     (progn 
  108.       (setq XY (ssname points index)) 
  109.       (setq XY (cdr (assoc 10 (entget XY)))) 
  110.       (setq pnts (append pnts XY)) 
  111.       (setq index (1- index)) 
  112.     ) 
  113.   ) 
  114.   (setq pnts (append pnts lastpt)) 
  115.   (command "undo" "1") 
  116.   (setq stop '()) 
  117.  
  118. ; 3DPOINTS - build 3dpoints for surfaces 
  119. (defun 3dpoints () 
  120.   (if (= firstpass nil) 
  121.     (progn 
  122.       (setq pt1 (list (nth next1 patha))) 
  123.       (setq next1 (1+ next1)) 
  124.       (setq pt1 (append pt1 (list (nth next1 patha)))) 
  125.       (setq pt1 (append pt1 elev1)) 
  126.       (setq pt2 (list (nth next2 pathb))) 
  127.       (setq next2 (1+ next2)) 
  128.       (setq pt2 (append pt2 (list (nth next2 pathb)))) 
  129.       (setq pt2 (append pt2 elev2)) 
  130.       (setq firstpass 1) 
  131.     ) 
  132.     (progn 
  133.       (setq pt1 pt3) 
  134.       (setq pt2 pt4) 
  135.     ) 
  136.   ) 
  137.   (setq next1 (1+ next1)) 
  138.   (setq pt3 (list (nth next1 patha))) 
  139.   (setq next1 (1+ next1)) 
  140.   (setq pt3 (append pt3 (list (nth next1 patha)))) 
  141.   (setq pt3 (append pt3 elev1)) 
  142.   (setq next2 (1+ next2)) 
  143.   (setq pt4 (list (nth next2 pathb))) 
  144.   (setq next2 (1+ next2)) 
  145.   (setq pt4 (append pt4 (list (nth next2 pathb)))) 
  146.   (setq pt4 (append pt4 elev2)) 
  147.  
  148. ;SFILL - The big cheese
  149. (defun c:SFILL (/ patha pathb elev1 elev2 next1 next2 firstpass) 
  150.   (setq res# (getstring (strcat "Resolution <"res">: ")))
  151.   (if (/= res# "")
  152.     (setq res res#)
  153.   )
  154.   (setvar "cmdecho" 0)
  155.   (spatha) 
  156.   (spathb) 
  157.   (setq next1 (setq next2 0)) 
  158.   (while (nth next2 pathb) 
  159.     (progn 
  160.       (3dpoints) 
  161.       (if (nth next2 pathb) 
  162.         (command "solid" pt1 pt2 pt3 pt4 "") 
  163.       ) 
  164.     ) 
  165.   ) 
  166.   (setq firstpass 0)
  167.   (setvar "cmdecho" 1) 
  168.